import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css' //全局样式
import './assets/css/font-awesome.min.css' //导入字体图标
//注册并使用富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

//引入nprogress
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

//配置axios
import axios from 'axios'
// 配置请求的基准URL地址
axios.defaults.baseURL = `http://127.0.0.1:8888/api/private/v1/`;
// axios设置请求拦截器,设置响应头token
axios.interceptors.request.use(
    config => {
        NProgress.start(); //在发送请求的时候(request), 开始进度条
        config.headers.Authorization = window.sessionStorage.getItem('token') //每次发送请求之前自动将在session中的token提取出来当做响应头header
        return config
    },
    err => {
        console.log(err)
    }
);
axios.interceptors.response.use(
    config => {
        NProgress.done(); //在请求发送完成的时候(repsonse), 结束进度条
        return config
    }
);
//把axios注册到Vue
Vue.prototype.$http = axios



Vue.use(VueQuillEditor, /* { default global options } */ )

//设置一个全局的过滤器  过滤时间格式
Vue.filter('dateFormat', function(nS) {
    return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/, '');
});

Vue.config.productionTip = false

new Vue({
    router,
    render: h => h(App)
}).$mount('#app')